﻿using Microsoft.AspNetCore.Components;
using SE.PO.CInterface.DBProtocols.Areas;
using SE.PO.CInterface.DBProtocols.Sites;
using SE.PO.CInterface.Web.Models;

namespace SE.PO.CInterface.Web.Pages.DB.Components;

public partial class SelectSite
{
    [Parameter] public  string Width { get; set; }
    
    [Parameter] public  string SiteId { get; set; }

    [Parameter] public dynamic Model { get; set; }

    private List<SelectModelItem> _sources = null!;

    protected override async Task OnInitializedAsync()
    {
        _sources = (from a in (await Client.GetPage(null, null, null)).Items
            select new SelectModelItem(a.SiteName, a.Id)).ToList();
    }

    private void OnSelectedItemChangedHandler(SelectModelItem? s)
    {
        if (s != null)
        {
            Model.SiteId = s.Value;
        }
    }
}